<%@page import="com.sinba.common.system.dto.RuleDTO"%>
<%@page import="com.sinba.common.user.dto.RegisterUserQueryDTO"%>
<%@page import="com.sinba.common.user.service.IRegisterUserService"%>
<%@page import="com.sinba.common.user.dto.RegisterUserDTO"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
if(session.getAttribute("password2")==null){
	response.sendRedirect( "login2.jsp?pageUrl=user/userUpgrade.jsp");
	return;
}
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IRegisterUserService registerUserService = (IRegisterUserService)ac.getBean("registerUserService");
RegisterUserQueryDTO qdto = new RegisterUserQueryDTO();
qdto.setLoginName((String)session.getAttribute("loginName"));
RegisterUserDTO registerUserDTO = registerUserService.findRegisterUserByIdOrLoginName(qdto);
request.setAttribute("registerUserDTO",registerUserDTO);
session.setAttribute("end", "会员升级");
session.setAttribute("middle", "个人管理");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><fmt:message key="i18n.touzhiLevelUpdate"/>-<fmt:message key="i18n.title"/> </title>
<link rel="shortcut icon" href="../index/favicon.png" />
<script type="text/javascript" src="${basePath}scripts/script.js"></script>
<jsp:include page="common.jsp"></jsp:include>
</head>
<body>
<jsp:include page="page_head.jsp"></jsp:include>
<div class="row">
	<div class="col-md-12">
			<div class="box border primary">
				<div class="box-title">
					<h4><i class="fa fa-bars"></i><fmt:message key="title.userUpgrade"/></h4>
				</div>
				<div class="box-body big">
					<h3 class="form-title"><fmt:message key="title.userUpgrade"/></h3>
					<form class="form-horizontal" role="form" action="registerUser!userOpt.action" id="userUpgrade_form">
						<input type="hidden" value="userUpgrade.jsp" name="pageUrl">
				  		<input type="hidden" value="UserUpgrade" name="optType">
				  		<input type="hidden" value="${session.loginName }" name="loginName">
				      <c:if test="${registerUserDTO.registerLevel eq 'L5' or registerUserDTO.registerLevel eq 'L6' }">
				      <div class="form-group">
						<label class="col-sm-3 control-label"></label>
						<div class="col-sm-9">
						  <fmt:message key="i18n.alreadyHighestLevel" />
						</div>
					  </div>
				      </c:if>
				      <c:if test="${registerUserDTO.registerLevel ne 'L5' }">
					 <div class="form-group">
							<label class="col-sm-3 control-label"><fmt:message key="i18n.userlevel" />：</label>
							<div class="col-sm-9">
							 <select class="form-control" id="registerLevel_reg1" name="upLevel">
								  <c:choose>  
								    <c:when test="${registerUserDTO.registerLevel eq 'L1'}">  
		   								<option value="L2"><fmt:message key="L2" />(<%=RuleDTO.level.get("L2") %>)</option> 
		   								<option value="L3"><fmt:message key="L3" />(<%=RuleDTO.level.get("L3") %>)</option> 
		   							    <option value="L4"><fmt:message key="L4" />(<%=RuleDTO.level.get("L4") %>)</option>
		   							    <option value="L5"><fmt:message key="L5" />(<%=RuleDTO.level.get("L5") %>)</option>
								    </c:when>  
								    <c:when test="${registerUserDTO.registerLevel=='L2'}">  
		   								<option value="L3"><fmt:message key="L3" />(<%=RuleDTO.level.get("L3") %>)</option> 
		   							    <option value="L4"><fmt:message key="L4" />(<%=RuleDTO.level.get("L4") %>)</option>
		   							    <option value="L5"><fmt:message key="L5" />(<%=RuleDTO.level.get("L5") %>)</option>
								    </c:when>  
								    <c:when test="${registerUserDTO.registerLevel=='L3'}">  
		   								<option value="L4"><fmt:message key="L4" />(<%=RuleDTO.level.get("L4") %>)</option>
		   							    <option value="L5"><fmt:message key="L5" />(<%=RuleDTO.level.get("L5") %>)</option>
								    </c:when>  
								    <c:when test="${registerUserDTO.registerLevel=='L4'}">  
	   								<option value="L5"><fmt:message key="L5" />(<%=RuleDTO.level.get("L5") %>)</option> 
						  		  </c:when>  
								</c:choose>
							</select>
						  </div>
					  </div>
					  <div class="form-group">
						<label class="col-sm-3 control-label"></label>
						<div class="col-sm-9">
						 	<c:if test="${not empty session.activationTime}">
			    			<c:if test="${registerUserDTO.registerLevel ne 'L5' }">
			    			<button onclick="userUpgrade()" class="btn btn-primary" style="width:15em;"><fmt:message key="title.userUpgrade" /></button>
							</c:if>
		   					</c:if>
						</div>
					  </div>
	  				</c:if>
					 </form>
				</div>
			</div>
		</div>
</div>
<jsp:include page="page_foot.jsp"></jsp:include>
<script type="text/javascript" src="../scripts/user/reguser.js"></script>


<script type="text/javascript">

$(function(){
	document.onkeydown = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			userUpgrade();
		}
	}
});	
</script>

</body>
</html>